//
//  MKUIEqualDivisionLayoutConstraint.h
//  MKUI
//  所有元素等分容器尺寸,在相同的单元格中显示
//  Created by 苏尚进 on 2025/7/10.
//  Copyright © 2025 moon. All rights reserved.
//

#import "MKUILayoutConstraint.h"

NS_ASSUME_NONNULL_BEGIN

@interface MKUIEqualDivisionLayoutConstraint : MKUILayoutConstraint
@property(nonatomic,assign) MKUILayoutConstraintDirection layoutDirection;//布局方向.默认为MKUILayoutConstraintDirectionHorizontal
@property(nonatomic,assign) MKUILayoutConstraintVerticalAlignment layoutVerticalAlignment;//所有元素作为一个整体,在垂直方向上的位置,以及每一个元素在整体内的垂直方向上的对齐方式.默认为MKUILayoutConstraintVerticalAlignmentCenter

@property(nonatomic,assign) MKUILayoutConstraintHorizontalAlignment layoutHorizontalAlignment;//所有元素作为一个整体,在水平方向上的位置,以及每一个元素在整体内的水平方向上的对方方式.默认为MKUILayoutConstraintHorizontalAlignmentCenter
@property(nonatomic,assign) UIEdgeInsets contentInsets;//内边距,默认为(0,0,0,0)
@property(nonatomic,assign) CGFloat interitemSpacing;//元素间的间隔,默认为0
@property(nonatomic,assign) BOOL itemFillCellBounds;//layout时，每个元素，是否充满单元格。默认为YES
@property(nonatomic,assign) BOOL fixSizeToFitsBounds;//在计算sizeThatFits时,根据布局方向,自动固定对应边的尺寸为传入的 size 的边,(如水平布局时,sizeThatFits.height=size.height),默认为 NO,即不固定
@end
typedef enum : NSUInteger {
    MKUIEqualDivisionLayoutConstraintParam_H_C_C,
    MKUIEqualDivisionLayoutConstraintParam_H_C_L,
    MKUIEqualDivisionLayoutConstraintParam_H_C_R,
    MKUIEqualDivisionLayoutConstraintParam_H_T_C,
    MKUIEqualDivisionLayoutConstraintParam_H_T_L,
    MKUIEqualDivisionLayoutConstraintParam_H_T_R,
    MKUIEqualDivisionLayoutConstraintParam_H_B_L,
    MKUIEqualDivisionLayoutConstraintParam_H_B_C,
    MKUIEqualDivisionLayoutConstraintParam_H_B_R,
    MKUIEqualDivisionLayoutConstraintParam_V_C_C,
    MKUIEqualDivisionLayoutConstraintParam_V_C_L,
    MKUIEqualDivisionLayoutConstraintParam_V_C_R,
    MKUIEqualDivisionLayoutConstraintParam_V_T_C,
    MKUIEqualDivisionLayoutConstraintParam_V_T_L,
    MKUIEqualDivisionLayoutConstraintParam_V_T_R,
    MKUIEqualDivisionLayoutConstraintParam_V_B_C,
    MKUIEqualDivisionLayoutConstraintParam_V_B_L,
    MKUIEqualDivisionLayoutConstraintParam_V_B_R,
} MKUIEqualDivisionLayoutConstraintParam;
MKAS_EnumTypeCategories(MKUIEqualDivisionLayoutConstraintParam)
@interface MKUIEqualDivisionLayoutConstraint(InitMethod)
- (id)initWithItems:(nullable NSArray<id<MKUILayoutConstraintItemProtocol>> *)items constraintParam:(MKUIEqualDivisionLayoutConstraintParam)param contentInsets:(UIEdgeInsets)contentInsets interitemSpacing:(CGFloat)interitemSpacing;
- (void)configWithConstraintParam:(MKUIEqualDivisionLayoutConstraintParam)param;
@property(nonatomic,assign) MKUIEqualDivisionLayoutConstraintParam constraintParam;

+ (void)parseConstraintParam:(MKUIEqualDivisionLayoutConstraintParam)param layoutDirection:(MKUILayoutConstraintDirection *)layoutDirection layoutVerticalAlignment:(MKUILayoutConstraintVerticalAlignment *)layoutVerticalAlignment layoutHorizontalAlignment:(MKUILayoutConstraintHorizontalAlignment *)layoutHorizontalAlignment;
+ (MKUIEqualDivisionLayoutConstraintParam)constraintParamWithLayoutDirection:(MKUILayoutConstraintDirection)layoutDirection layoutVerticalAlignment:(MKUILayoutConstraintVerticalAlignment)layoutVerticalAlignment layoutHorizontalAlignment:(MKUILayoutConstraintHorizontalAlignment)layoutHorizontalAlignment;
@end
NS_ASSUME_NONNULL_END
/**
 *
 以下为layoutDirection,layoutVerticalAlignment,layoutHorizontalAlignment的18种组合:
 
 MKUIEqualDivisionLayoutConstraintParam_H_C_C
 layoutDirection = MKUILayoutConstraintDirectionHorizontal;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentCenter;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentCenter;
 :
 _________
|                    |
|         B         |
|    A   B   C   |
|         B         |
|__________|
 
 MKUIEqualDivisionLayoutConstraintParam_H_C_L
 layoutDirection = MKUILayoutConstraintDirectionHorizontal;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentCenter;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentLeft;
:
 _________
|                      |
|       B             |
|A     B     C     |
|       B             |
|__________  |
 
 MKUIEqualDivisionLayoutConstraintParam_H_C_R
 layoutDirection = MKUILayoutConstraintDirectionHorizontal;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentCenter;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentRight;
 :
 _________
|                     |
|            B       |
|     A     B     C|
|            B       |
|__________ |
 
 MKUIEqualDivisionLayoutConstraintParam_H_T_C
 layoutDirection = MKUILayoutConstraintDirectionHorizontal;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentTop;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentCenter;
 :
 __________
|      A B C      |
|         B C      |
|         B          |
|                     |
|__________ |
 
 MKUIEqualDivisionLayoutConstraintParam_H_T_L
 layoutDirection = MKUILayoutConstraintDirectionHorizontal;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentTop;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentLeft;
 :
 __________
|A B C            |
|   B C            |
|   B                |
|                     |
|__________ |
 
 MKUIEqualDivisionLayoutConstraintParam_H_T_R
 layoutDirection = MKUILayoutConstraintDirectionHorizontal;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentTop;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentRight;
 :
 __________
|            A B C|
|               B C|
|               B    |
|                     |
|__________ |

 MKUIEqualDivisionLayoutConstraintParam_H_B_L
 layoutDirection = MKUILayoutConstraintDirectionHorizontal;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentBottom;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentLeft;
 :
  ________
 |                 |
 |                 |
 |     B          |
 |     B C      |
 |A_B_C___|
 
 MKUIEqualDivisionLayoutConstraintParam_H_B_C
 layoutDirection = MKUILayoutConstraintDirectionHorizontal;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentBottom;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentCenter;
 :
  _________________
 |                                   |
 |                                   |
 |                B                 |
 |                B   C           |
 |______A_B_C______|
 
 MKUIEqualDivisionLayoutConstraintParam_H_B_R
 layoutDirection = MKUILayoutConstraintDirectionHorizontal;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentBottom;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentRight;
 :
  _________________
 |                                   |
 |                                   |
 |                            B     |
 |                            B  C|
 |____________A_B_C|
 
 MKUIEqualDivisionLayoutConstraintParam_V_C_C
 layoutDirection = MKUILayoutConstraintDirectionVertical;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentCenter;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentCenter;
 :
 ____
|          |
|    A    |
| BBB  |
|    C    |
|_____|
 
 MKUIEqualDivisionLayoutConstraintParam_V_C_L
 layoutDirection = MKUILayoutConstraintDirectionVertical;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentCenter;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentLeft;
 :
 ____
|          |
|A        |
|BBB   |
|CC     |
|_____|
 
 MKUIEqualDivisionLayoutConstraintParam_V_C_R
 layoutDirection = MKUILayoutConstraintDirectionVertical;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentCenter;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentRight;
 :
 ____
|         |
|       A|
|  BBB|
|    CC|
|_____|
 
 MKUIEqualDivisionLayoutConstraintParam_V_T_C
 layoutDirection = MKUILayoutConstraintDirectionVertical;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentTop;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentCenter;
 :
 ____
|    A   |
| BBB |
|    C  |
|         |
|____ |
 
 MKUIEqualDivisionLayoutConstraintParam_V_T_L
 layoutDirection = MKUILayoutConstraintDirectionVertical;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentTop;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentLeft;
 :
 ____
|A       |
|BBB  |
|CC    |
|         |
|____ |
 
 MKUIEqualDivisionLayoutConstraintParam_V_T_R
 layoutDirection = MKUILayoutConstraintDirectionVertical;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentTop;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentRight;
 :
 ____
|     A  |
|  BBB|
|   CC |
|         |
|____ |
 
 MKUIEqualDivisionLayoutConstraintParam_V_B_C
 layoutDirection = MKUILayoutConstraintDirectionVertical;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentBottom;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentCenter;
 :
 ____
|         |
|         |
|    A   |
| BBB |
|__C_ |
 
 MKUIEqualDivisionLayoutConstraintParam_V_B_L
 layoutDirection = MKUILayoutConstraintDirectionVertical;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentBottom;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentLeft;
 :
 ____
|          |
|          |
|A        |
|BBB   |
|CC__ |
 
 MKUIEqualDivisionLayoutConstraintParam_V_B_R
 layoutDirection = MKUILayoutConstraintDirectionVertical;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentBottom;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentRight;
 :
 _____
|           |
|           |
|         A|
|    BBB|
|___CC|
 */
